
<html>

<head>
    <meta charset="UTF-8">
    <script src="js/jquery-3.7.1.min.js"></script>
    <script>
        function getBrowserUrls(){
            var url = window.location.href;
            let urlParams = new URLSearchParams(url.split('?')[1]);
            console.log("urlParams:"+urlParams)

             let reurl = url.substring(0,url.lastIndexOf("?"));
             console.log("reurl:"+reurl)

            ones(reurl,urlParams);
        }
        function ones(url,args){
            console.log("url:"+url+",args:"+args)
            $.ajax({
                url:'http://127.0.0.1:9006/oauth/token?grant_type=authorization_code&'+args+'&redirect_uri='+url+'',
                type:'GET',
                success: function (response){
                    console.log(response);
                    let token = response.access_token;
                    let tokenType = response.token_type;
                    console.log("token:"+token)
                    getUser(tokenType,token);

                },
                error:function (xhr,status,error){
                    alert(error)
                }
            });
        }

        function getUser(arsg,token){
            $.ajax({
                url:'http://127.0.0.1:9003/oauth2/getUser',
                type:'POST',
                contentType:"application/json;charset=utf-8",
                headers:{
                  "Authorization": arsg+ " "+token
                },
                data:JSON.stringify({
                    "token":token
                }),
                success: function (response){
                    console.log(response);

                },
                error:function (xhr,status,error){
                    alert(error)
                }
            });
        }
    </script>
</head>
    <body onload="getBrowserUrls()">
        <h1 >hello word!!!</h1>
        <p>this is a html page</p>
    </body>
</html>